load("@build_bazel_rules_android//android:rules.bzl", "android_library")

licenses(["notice"])

package(default_visibility = ["//visibility:public"])

java_library(
    name = "jwt_mac",
    srcs = ["JwtMac.java"],
    deps = [
        ":jwt",
        ":jwt_validator",
        ":to_be_signed_jwt",
        "@maven//:com_google_errorprone_error_prone_annotations",
    ],
)

java_library(
    name = "jwt",
    srcs = ["Jwt.java"],
    deps = [
        ":jwt_expired_exception",
        ":jwt_names",
        ":jwt_not_before_exception",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven//:org_json_json",
    ],
)

java_library(
    name = "jwt_names",
    srcs = ["JwtNames.java"],
)

java_library(
    name = "to_be_signed_jwt",
    srcs = ["ToBeSignedJwt.java"],
    deps = [
        ":jwt_names",
        "//src/main/java/com/google/crypto/tink/subtle:base64",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven//:org_json_json",
    ],
)

java_library(
    name = "jwt_not_before_exception",
    srcs = ["JwtNotBeforeException.java"],
)

java_library(
    name = "jwt_expired_exception",
    srcs = ["JwtExpiredException.java"],
)

java_library(
    name = "jwt_invalid_exception",
    srcs = ["JwtInvalidException.java"],
)

java_library(
    name = "jwt_validator",
    srcs = ["JwtValidator.java"],
    deps = [
        ":jwt",
        ":jwt_expired_exception",
        ":jwt_invalid_exception",
        ":jwt_names",
        ":jwt_not_before_exception",
        ":to_be_signed_jwt",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven//:org_json_json",
    ],
)

java_library(
    name = "jwt_hmac",
    srcs = ["JwtHmac.java"],
    deps = [
        ":jwt",
        ":jwt_invalid_exception",
        ":jwt_mac",
        ":jwt_validator",
        ":to_be_signed_jwt",
        "//src/main/java/com/google/crypto/tink:mac",
        "//src/main/java/com/google/crypto/tink/subtle:base64",
        "//src/main/java/com/google/crypto/tink/subtle:prf_hmac_jce",
        "//src/main/java/com/google/crypto/tink/subtle:prf_mac",
        "@maven//:com_google_errorprone_error_prone_annotations",
    ],
)

java_library(
    name = "jwt_hmac_key_manager",
    srcs = ["JwtHmacKeyManager.java"],
    deps = [
        ":jwt_hmac",
        ":jwt_mac",
        "//proto:common_java_proto",
        "//proto:jwt_hmac_java_proto",
        "//proto:tink_java_proto",
        "//src/main/java/com/google/crypto/tink:key_template",
        "//src/main/java/com/google/crypto/tink:key_type_manager",
        "//src/main/java/com/google/crypto/tink:registry_cluster",
        "//src/main/java/com/google/crypto/tink/subtle:random",
        "//src/main/java/com/google/crypto/tink/subtle:validators",
        "@com_google_protobuf//:protobuf_javalite",
    ],
)

java_library(
    name = "jwt_mac_wrapper",
    srcs = ["JwtMacWrapper.java"],
    deps = [
        ":jwt",
        ":jwt_mac",
        ":jwt_validator",
        ":to_be_signed_jwt",
        "//src/main/java/com/google/crypto/tink:primitive_set",
        "//src/main/java/com/google/crypto/tink:primitive_wrapper",
        "//src/main/java/com/google/crypto/tink:registry_cluster",
        "@maven//:com_google_errorprone_error_prone_annotations",
    ],
)

java_library(
    name = "jwt_mac_config",
    srcs = ["JwtMacConfig.java"],
    deps = [
        ":jwt_hmac_key_manager",
        ":jwt_mac_wrapper",
    ],
)

# Android libraries

android_library(
    name = "jwt_mac-android",
    srcs = ["JwtMac.java"],
    deps = [
        ":jwt-android",
        ":jwt_validator-android",
        ":to_be_signed_jwt-android",
        "@maven//:com_google_errorprone_error_prone_annotations",
    ],
)

android_library(
    name = "jwt-android",
    srcs = ["Jwt.java"],
    deps = [
        ":jwt_expired_exception",
        ":jwt_names",
        ":jwt_not_before_exception",
        "@maven//:com_google_errorprone_error_prone_annotations",
    ],
)

android_library(
    name = "to_be_signed_jwt-android",
    srcs = ["ToBeSignedJwt.java"],
    deps = [
        ":jwt_names",
        "//src/main/java/com/google/crypto/tink/subtle:base64",
        "@maven//:com_google_errorprone_error_prone_annotations",
    ],
)

android_library(
    name = "jwt_validator-android",
    srcs = ["JwtValidator.java"],
    deps = [
        ":jwt-android",
        ":jwt_expired_exception",
        ":jwt_invalid_exception",
        ":jwt_names",
        ":jwt_not_before_exception",
        ":to_be_signed_jwt-android",
        "@maven//:com_google_errorprone_error_prone_annotations",
    ],
)

android_library(
    name = "jwt_hmac-android",
    srcs = ["JwtHmac.java"],
    deps = [
        ":jwt-android",
        ":jwt_invalid_exception",
        ":jwt_mac-android",
        ":jwt_validator-android",
        ":to_be_signed_jwt-android",
        "//src/main/java/com/google/crypto/tink:mac",
        "//src/main/java/com/google/crypto/tink/subtle:base64",
        "//src/main/java/com/google/crypto/tink/subtle:prf_hmac_jce",
        "//src/main/java/com/google/crypto/tink/subtle:prf_mac",
        "@maven//:com_google_errorprone_error_prone_annotations",
    ],
)

android_library(
    name = "jwt_hmac_key_manager-android",
    srcs = ["JwtHmacKeyManager.java"],
    deps = [
        ":jwt_hmac-android",
        ":jwt_mac-android",
        "//proto:common_java_proto_lite",
        "//proto:jwt_hmac_java_proto_lite",
        "//proto:tink_java_proto_lite",
        "//src/main/java/com/google/crypto/tink:key_template-android",
        "//src/main/java/com/google/crypto/tink:key_type_manager-android",
        "//src/main/java/com/google/crypto/tink:registry_cluster-android",
        "//src/main/java/com/google/crypto/tink/subtle:random",
        "//src/main/java/com/google/crypto/tink/subtle:validators",
        "@com_google_protobuf//:protobuf_javalite",
    ],
)

android_library(
    name = "jwt_mac_wrapper-android",
    srcs = ["JwtMacWrapper.java"],
    deps = [
        ":jwt-android",
        ":jwt_mac-android",
        ":jwt_validator-android",
        ":to_be_signed_jwt-android",
        "//src/main/java/com/google/crypto/tink:primitive_set-android",
        "//src/main/java/com/google/crypto/tink:primitive_wrapper-android",
        "//src/main/java/com/google/crypto/tink:registry_cluster-android",
        "@maven//:com_google_errorprone_error_prone_annotations",
    ],
)

android_library(
    name = "jwt_mac_config-android",
    srcs = ["JwtMacConfig.java"],
    deps = [
        ":jwt_hmac_key_manager-android",
        ":jwt_mac_wrapper-android",
    ],
)
